package b1.conifg
{
	import b1.conifg.story.*;
	import b1.players.*;

	public class VirtualPlayerConfig extends PlayerInfo
	{
		public var homeIconImage:String;
		//是否显示到作案当中
		public var appearInCrimeFlag:Boolean;
		//家中可能出现的boss的概率(id为索引),每个元素为数组，分别为【boss的id,出现的概率,出现时讲的话】
		public var bossesAppear:Object;
		//魔塔层
		public var towerConfig:TowerConfig;
		
		public function VirtualPlayerConfig(virtualPlayerXML:XML=null)
		{
			super();
			this.id = parseInt(virtualPlayerXML.id);
			this.type = parseInt(virtualPlayerXML.type);
			this.name = virtualPlayerXML.name;
			this.homeIndex = parseInt(virtualPlayerXML.homeIndex);
			this.homeIconImage = virtualPlayerXML.homeIconImage;
			this.appearInCrimeFlag = Boolean(parseInt(virtualPlayerXML.appearInCrimeFlag));
			
			//解析动物信息
			for (var i:int = 0; i < virtualPlayerXML.animal.length(); i++)
			{
				var virtualAnimalInfo:VirtualAnimalConfig = new VirtualAnimalConfig(virtualPlayerXML.animal[i]);
				PlayerInfoHelper.getInstance().animals[virtualAnimalInfo.id] = virtualAnimalInfo;
				//拥有的动物
				this.ownAnimals.push(virtualAnimalInfo.id);
				//目前居住的动物
				this.liveAnimals.push(virtualAnimalInfo.id);
			}
			//解析包裹信息
			for (i = 0; i < virtualPlayerXML.userPackage.length(); i++)
			{
				this.userPackage = new PackageInfo(virtualPlayerXML.userPackage[i]);
			}
			//解析可能出现的boss信息
			this.bossesAppear = new Object();
			for (i = 0; i < virtualPlayerXML.bossAppear.length(); i++)
			{
				var bossAppearInfo:Array = virtualPlayerXML.bossAppear[i].split(",");				
				var bossId:int = bossAppearInfo[0];
				bossesAppear[bossId] = bossAppearInfo;
			}
			//解析魔塔层
			towerConfig = new TowerConfig(virtualPlayerXML);
		}
		
	}
}